<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>Login Page | Amaze UI Example</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="format-detection" content="telephone=no">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <script src="/static/react/js/jquery.min.js"></script>
    <script src="/static/react/js/vendor.js"></script>
    <script src="/static/react/js/login.js"></script>
    <script>require('login/initialize');</script>
    <link rel="alternate icon" type="image/png" href="assets/i/favicon.png">
    <link rel="stylesheet" href="/static/react/css/amazeui.min.css"/>
    <link rel="stylesheet" href="/static/react/css/login.css">
    <style>
        .header {
            text-align: center;
        }

        .header h1 {
            font-size: 200%;
            color: #78798d;
            margin-top: 0px;
        }

        .header p {
            font-size: 14px;
            color: #78798d;
        }
    </style>
    <!--script type="text/javascript" src="static/assets/js/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#register_button').click(function () {
                $('#input_username').hide();
            });
        });
    </script-->

    <script type="text/javascript">
        function imgPreview(fileDom){
            //判断是否支持FileReader
            if (window.FileReader) {
                var reader = new FileReader();
            } else {
                alert("您的设备不支持图片预览功能，如需该功能请升级您的设备！");
            }

            //获取文件
            var file = fileDom.files[0];
            var imageType = /^image\//;
            //是否是图片
            if (!imageType.test(file.type)) {
                alert("请选择图片！");
                return;
            }
            //读取完成
            reader.onload = function(e) {
                //获取图片dom
                var img = document.getElementById("preview");
                //图片路径设置为读取的图片
                img.src = e.target.result;
            };
            reader.readAsDataURL(file);
        }

        function validate(){
            console.log("click state");
            var name = $("#account2").val();
            var pwd = $("#password_l").val();

            $.post("/login", { account: name, password: pwd }, function (data) {
                console.log(data);

                if (data.ok === true) {
                    alert("登录成功");
                    window.location.href = "/recommend";

                } else {
                    alert(data.brief);
                }
            });
        }
    </script>

</head>

<body>

<div class="am-g myapp-login">
    <div class="wrapper-page">

        <div class="header">
            <div class="am-g">
                <a href="index.html">
                <h1>漂流书单</h1>
                </a>
                <p>让我们在书籍的海洋里放飞自我吧</p>
            </div>
        </div>

        <div class="myapp-login-bg">

            <div data-am-widget="tabs" class="am-tabs am-tabs-d2">
                <ul class="am-tabs-nav am-cf">
                    <li class="am-active" id="register_panel"><a href="[data-tab-panel-0]">注册</a></li>
                    <li class="" id="login_panel"><a href="[data-tab-panel-1]">登录</a></li>
                </ul>

                <div class="am-tabs-bd">
                    <div data-tab-panel-0 class="am-tab-panel am-active" id="panel0">
                        <form action="/register" enctype="multipart/form-data" method="post" class="am-form" data-am-validator id="rp1">
                            <fieldset>
                                <div class="am-form-group" id="input_username">
                                    <label for="account">User Name</label>
                                    <input type="text" id="account" name="account" minlength="3" placeholder="请输入3位以上用户名"
                                           class="am-form-field" required/>
                                </div>
                                <div class="am-form-group" id="input_username">
                                    <label for="name">昵称</label>
                                    <input type="text" id="name" name="name" placeholder="请输入昵称"
                                           class="am-form-field" required/>
                                </div>
                                <div class="am-form-group">
                                    <label for="password">Password</label>
                                    <input type="password" name="password" id="password" minlength="5" placeholder="请输入5位以上密码"
                                           class="am-form-field" required/>
                                </div>
                                <div class="am-form-group">
                                    <label for="password_r1">Password</label>
                                    <input type="password" id="password_r1" minlength="5" placeholder="确认密码"
                                           data-equal-to="#password" class="am-form-field" required/>
                                </div>

                                <div class="am-form-group">
                                    <label for="birthday" class="am-u-sm-3 am-form-label">生日</label>
                                    <input type="text" name="birthday" id="birthday" class="am-form-field tpl-form-no-bg" placeholder="选择生日" data-am-datepicker="" readonly/>

                                </div>

                                <div class="am-form-group">
                                    <label for="doc-form-file" class="am-u-sm-3 am-form-label">头像</label>
                                        <div class="am-form-group am-form-file">
                                            <div class="" style="width: 50px; height: 50px;">
                                                <img id="preview" style="width:50px; height:50px;" src="/static/react/i/01.jpg" alt="">
                                            </div>
                                        </div>
                                    <div class="am-form-file">
                                        <button type="button" class="am-btn am-btn-danger am-btn-sm">
                                            <i class="am-icon-cloud-upload"></i> 添加头像</button>
                                        <input onchange="imgPreview(this)" name="pic_src" id="doc-form-file" type="file" multiple>
                                    </div>

                                </div>

                                <div class="am-form-group myapp-login-treaty">
                                    <label class="am-form-label"></label><label class="am-checkbox-inline">
                                        <input type="radio" name="gender" value="male"/>男
                                    </label>
                                    <label class="am-form-label"></label><label class="am-checkbox-inline">
                                        <input type="radio" name="gender" value="female" checked>女
                                    </label>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-intro" class="am-u-sm-3 am-form-label">简介</label>
                                    <textarea style="background: none;" name="introduction" class="am-form-field" rows="1" id="user-intro" placeholder="输入个人简介"></textarea>
                                </div>

                                <button class="myapp-login-button am-btn am-btn-secondary"
                                         id="register_button" type="submit">Register
                                </button>
                            </fieldset>
                        </form>
                    </div>

                    <div data-tab-panel-1 class="am-tab-panel" id="panel1">
                        <div class="am-form" id="rp2">
                            <fieldset>
                                <div class="am-form-group">
                                    <label for="account2">User Name</label>
                                    <input type="text" id="account2" name="account" minlength="3" placeholder="请输入用户名"
                                           class="am-form-field" required/>
                                </div>
                                <div class="am-form-group">
                                    <label for="password_l">Password</label>
                                    <input type="password" id="password_l" name="password" minlength="5" placeholder="请输入密码"
                                           class="am-form-field" required/>
                                </div>

                                <!--div class="am-form-group myapp-login-treaty"><label class="am-form-label"></label><label class="am-checkbox-inline"> <input type="checkbox" value="橘子" name="docVlCb" minchecked="2" maxchecked="4" required="">已同意使用条约 </label></div-->
                                <br/>
                                <button class="myapp-login-button am-btn am-btn-secondary" id="login_button"
                                onclick="validate()" >SIGN IN
                                </button>
                            </fieldset>
                            <legend>Forgot Password?</legend>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
<!--/div-->
<!--[if (gte IE 9)|!(IE)]><!-->
<!--<![endif]-->
<!--[if lte IE 8 ]>
<script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="/static/react/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->
<script src="/static/react/js/amazeui.min.js"></script>
<script src="/static/react/js/calendar.js"></script>
</body>
</html>
